package com.ecosoft.config;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import com.ecosoft.config.AppContext;
import com.ecosoft.config.ConfigContainer;

public class InitEcoAppServlet extends HttpServlet {
	private static final long serialVersionUID = 5748251292460981883L;
	/**
	 * Constructor of the object.
	 */
	public InitEcoAppServlet() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}


	/**
	 * Initialization of the servlet. <br>
	 *
	 * @throws ServletException if an error occurs
	 */
	public void init() throws ServletException {
		String prefix =  getServletContext().getRealPath("/");
		String config_dir= prefix+getInitParameter("config-dir");
		ConfigContainer.getInstance().setConfigDir(config_dir);
		ConfigContainer.getInstance().initContainer();
		AppContext.getContext().setAppRootCategoryPath(prefix);
		AppContext.getContext().setAppContextPath(this.getServletContext().getContextPath());
	}

}
